<?php
/* SVN FILE: $Id: test_case.php 11 2009-09-12 23:39:35Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-12 23:39:35 +0000 (Sat, 12 Sep 2009) $
 * $Revision: 11 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/models/test_case.php $
 */
class TestCase extends AppModel {
  var $name = 'TestCase';
  var $hasMany = 'AssessmentTestCase';
  var $validate = array('name' => array('rule' => array('minLength',1)),
                        'description' => array('rule' => array('minLength',1)));
  
  function getForUserAssignment($user_id, $assignment_id)
  {
    return $this->query("SELECT tc.id,tc.name,tc.description " .
                        "  FROM test_cases AS tc " .
                        "  JOIN assessment_test_cases AS at ON at.test_case_id = tc.id " .
                        "  JOIN assessments AS a ON a.id = at.assessment_id " .
                        "  JOIN submissions AS s ON s.id = a.submission_id " . 
                        " WHERE tc.user_id = {$user_id} " .
                        "   AND s.assignment_id = {$assignment_id}");
  } 
}
?>